<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>第一个循环数据</title>
    <style>
      .person {
        background: pink;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <script src="./libs/react.js"></script>
    <script src="./libs/react-dom.js"></script>
    <script src="./libs/babel.min.js"></script>
    <script type="text/babel">
      function Person(props) {
        return (
          <li className="person" style={{ color: props.color }}>
            {props.name}
          </li>
        );
      }
      function People() {
        const person = ["1", "2", "3"];
        return (
          <ul>
            {person.map((item, index) => (
              <Person
                key={index}
                name={item}
                color={item % 2 == 0 ? "red" : "blue"}
              />
            ))}
          </ul>
        );
      }
      ReactDOM.render(<People />, document.getElementById("app"));
    </script>
  </body>
</html>
